package com.briup.app01.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.briup.app01.bean.CstLinkman;
import com.briup.app01.bean.CstLinkmanExample;
import com.briup.app01.bean.CstLinkmanExample.Criteria;
import com.briup.app01.dao.CstLinkmanMapper;
import com.briup.app01.service.CstLinkmanService;
@Service
public class CstLinkmanServiceImpl implements CstLinkmanService {
	@Autowired
	private CstLinkmanMapper linkmanMapper;
	public void saveOrUpdate(CstLinkman linkman) {
		if(linkman.getLkmCustId()==null) {
			linkmanMapper.insertSelective(linkman);
		}else {
		       linkmanMapper.updateByPrimaryKey(linkman);
	     }
	}
	public void deleteById(long id) {
		linkmanMapper.deleteByPrimaryKey(id);
	}
	public CstLinkman selectById(long id) {
		return linkmanMapper.selectByPrimaryKey(id);
	}
	
	public List<CstLinkman> select(String name, String sex,String position) {
		CstLinkmanExample example = new CstLinkmanExample();
    	Criteria criteria = example.createCriteria();
    	if(name!=null) {
    		criteria.andLkmNameLike("%"+name+"%");
    	}
    	if(sex!=null) {
    		criteria.andLkmSexLike("%"+sex+"%");
    }
    	if(position!=null) {
    		criteria.andLkmPostionLike("%"+position+"%");
    	}
    		return linkmanMapper.selectByExample(example);
	}
	
	}
	
	
	
	
